<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<script type="text/javascript">
			//3. 开发游戏有如下类，请尝试声明父类，下面所有类继承这个父类。
			function Base(name, level) {
				this.name = name;
				this.level = level;
			}
			
			function F() {} 
			F.prototype = Base.prototype; // 
			
			function Human(name, level, sex) {
				Base.call(this, name, level); 
				this.sex = sex;
			}
			function Creep(name, level, exp) {
				Base.call(this, name, level); 
				this.exp = exp;
			}
			function Item(name, level, type) {
				Base.call(this, name, level); 
				this.type = type;
			}
			
			Base.prototype.desc = function() { // 描述对象的方法
				console.log("姓名：" + this.name + "，等级：" + this.level + "，性别：" + this.sex);
			}
			Base.prototype.expe = function() { // 描述对象的方法
				console.log("名称：" + this.name + "，等级：" + this.level + "，经验值：" + this.exp);
			}
			Base.prototype.typ = function() { // 描述对象的方法
				console.log("名称：" + this.name + "，等级：" + this.level + "，类型：" + this.type);
			}
		
			Human.prototype = new F(); 
			Human.prototype.constructor = Human; 
			
			Creep.prototype = new F();
			Creep.prototype.constructor = Creep; 
			
			Item.prototype = new F();
			Item.prototype.constructor = Item; 
			
			let human = new Human("艾达", 90, "男");
			console.log("human", human);
			human.desc();
			let creep = new Creep("史莱克",80, 260);
			console.log("creep", creep);
			creep.expe();
			let item = new Item("异度之刃",70, "刀剑");
			console.log("item", item);
			item.typ();
			
		</script>
	</body>
</html>
